//
//  WbStatusesPictureCell.swift
//  Weibo
//
//  Created by HH on 16/12/7.
//  Copyright © 2016年 Weibo. All rights reserved.
//

import UIKit
import SDWebImage
import SnapKit

class WbStatusesPictureCell: UICollectionViewCell {
    
    var pictureModel:WbStatusesPictureModel?{
        
        didSet{
            //下载图片
            pictureView.sd_setImage(with: URL(string:(pictureModel?.thumbnail_pic)!), placeholderImage: #imageLiteral(resourceName: "timeline_image_placeholder"))
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //配图View
    lazy private var pictureView:UIImageView = {
        
        let imageView = UIImageView()
        //设置图片模式
        imageView.contentMode = .scaleAspectFill
        //多余的部分减去
        imageView.clipsToBounds = true
        
        imageView.backgroundColor = UIColor.randomColor()
        
        return imageView
        
    }()
    
    
    private func setupUI(){
        
        contentView.addSubview(pictureView)
        
        //这样设置约束会解决一个约束bug
        pictureView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    
}
